#include<bits/stdc++.h>
using namespace std;
int main() {
	int t,k;
	long long n;
	cin >> t;
	while(t--) {
		cin>>k>>n;
		long long d=9;
		for(int i = 2;i <= k;i++)
			d = d * 10 + 9;
		if(n % d == 0) cout << "aya" << endl;
		else cout<<"baka" << endl;
	}
	return 0;
}

